import java.util.Scanner;
import java.util.Stack;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String input;
		char[] spInput;
		Stack<Integer> operands;
		int sum;

		while(sc.hasNext()) {
			input = sc.nextLine();
			spInput = input.toCharArray();
			
			if(input.equals("0"))
				{ System.exit(0); }
			
			operands = new Stack<Integer>();
			sum = 0;
			
			for(int i = 0; i < spInput.length; i++) {
				if( Character.isDigit(spInput[i]) ) {
					operands.push( Integer.parseInt(Character.toString(spInput[i])) );
				} else {
					char operator = spInput[i];
					int b = operands.pop();
					int a = operands.pop();
					
					if(operator == '+')
						{ operands.push((a + b)); }
					else if(operator == '-')
						{ operands.push((a - b)); }
					else if(operator == '*')
						{ operands.push((a * b)); }
					else if(operator == '/')
						{ operands.push((a / b)); }
					else
						{ operands.push((a % b)); }
				}
				
				if( (!(Character.isDigit(spInput[spInput.length - 1])) && (i == (spInput.length - 1))) )
					{ sum = operands.pop(); }
				else if(spInput.length == 1)
					{ sum = operands.pop(); }
			}
			
			System.out.println(Integer.toString(sum));
		}
	}
}